package com.lin.controller;


import com.lin.base.Result;
import com.lin.entity.Department;
import com.lin.service.impl.DepartmentServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author lin
 * @since 2022-06-17
 */
@RestController
@RequestMapping("/api/department")
public class DepartmentController {
    @Resource
    DepartmentServiceImpl departmentService;

    @GetMapping("/list")
    public Result getDepartmentList(@RequestParam Integer page,
                                    @RequestParam Integer size,
                                    @RequestParam Integer condition,
                                    @RequestParam String key) {
        return Result.ok(departmentService.getDepartmentList(page,size,condition,key));
    }
    @PostMapping("/add")
    public Result addDepartment(@RequestBody Department department) {
        return Result.ok(departmentService.addDepartment(department));
    }
    @PostMapping("/update")
    public Result updateDepartment(@RequestBody Department department) {
        return Result.ok(departmentService.updateDepartment(department));
    }
    @PostMapping("/remove")
    public Result removeDepartment(@RequestParam Integer did) {
        return Result.ok(departmentService.removeDepartment(did));
    }

}
